package org.mistfx.mvp.views;

import javafx.scene.Parent;
import rx.Observable;

/**
 * Created on 2015-10-30.
 *
 * @author Misty
 */
public abstract class FXMLViewRx<T> extends FXMLView<T> {
    private Observable<Parent> viewObs = Observable.<Parent>create(subscriber -> {
//        System.out.println("obs view " + this);
        subscriber.onNext(getView());
        subscriber.onCompleted();
    }).cache();

    public Observable<Parent> getViewObs() {
        return viewObs;
    }

    private Observable<T> presenterObs = Observable.<T>create(subscriber -> {
//        System.out.println("obs presenter " + this);
        subscriber.onNext(getPresenter());
        subscriber.onCompleted();
    }).cache();

    public Observable<T> getPresenterObs() {
        return presenterObs;
    }
}
